import type zhCN from '../locales/zh-CN.json'

export type Lang = 'zh-CN' | 'en-US'

export type MessageSchema = typeof zhCN

type Concat<K extends string, V extends string> = `${K}.${V}`

export type Flatten<T, K extends string = ''> =
  T extends Record<string, never>
    ? {
      // eslint-disable-next-line @typescript-eslint/ban-ts-comment
      // @ts-ignore
      [P in keyof T]: Flatten<T[P], K extends '' ? P : Concat<K, P & string>>
    }[keyof T]
    : K

export type MessageKeySchema = Flatten<MessageSchema>
